package com.fanghuyun.iswaf.common;

import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

import com.fanghuyun.iswaf.util.StringUtil;

public class HttpServletRequestContentWrapper extends HttpServletRequestWrapper{

	private Map<String,Object> map = null;
	
	public String getAcceptCharset(HttpServletRequest request){
		String charSet = request.getHeader("Accept-Charset");
		return StringUtil.isNotEmpty(charSet)?charSet.substring(charSet.indexOf("Accept-Charset:",charSet.indexOf(",")+1)):System.getProperty("sun.jnu.encoding");
	}
	
	public HttpServletRequestContentWrapper(HttpServletRequest request) {
		super(request);
	}
	
	public HttpServletRequestContentWrapper(HttpServletRequest request,Map<String,Object> map) {
		super(request);
		this.map = map;
	}
	
	public String getParameter(String name) {
		String value = super.getParameter(name);
		if(map!=null&&map.get(name)!=null){
			value = (String)map.get(name);
		}
		return value;
	}
	
}
